//
//  TopUpVC.m
//  jinwang
//
//  Created by jzb on 2018/3/12.
//  Copyright © 2018年 jzb. All rights reserved.
//

#import "TopUpVC.h"

@interface TopUpVC ()
{
    NSString *_payType;
}
@property (weak, nonatomic) IBOutlet UITextField *jineTF;
@property (weak, nonatomic) IBOutlet UIImageView *ZFBIconImg;
@property (weak, nonatomic) IBOutlet UIImageView *WXIconImg;

@end

@implementation TopUpVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"充值";
    self.view.backgroundColor = [UIColor whiteColor];
    
    _payType = @"0";
}

- (IBAction)ZFChoseBtnOnclick:(UIButton *)sender {
    _ZFBIconImg.image = [UIImage imageNamed:@"jw_grayYuan"];
    _WXIconImg.image = [UIImage imageNamed:@"jw_grayYuan"];
    
    if (sender.tag == 1000) {
        _ZFBIconImg.image = [UIImage imageNamed:@"jw_sex_btn_sel"];
        _payType = @"0";
    }else{
        _WXIconImg.image = [UIImage imageNamed:@"jw_sex_btn_sel"];
        _payType = @"1";
    }
}

- (IBAction)TopUpBtnOnclick:(UIButton *)sender {
    
    if (kStringIsEmpty(_jineTF.text)) {
        
        [self showBottomMessag:@"请输入您要充值的金额"];
        
    }else{
        
        [[DDNetworkManagerDate makeUrl_recharge_with_token:k_user_token type:_payType money:_jineTF.text] post_RequestFinshSuccess:^(id responseObject) {
            
            NSLog(@"-=-=->>%@",responseObject);
            if ([self requestFinshCode:responseObject isShowMessage:YES] == 1) {
                
                if ([_payType isEqualToString:@"0"]) {
                    NSString *dataStr = [responseObject objectForKey:@"data"];
                    
                    [[LeoPayManager getInstance]aliPayOrder:dataStr scheme:@"jinwangAlpay" respBlock:^(NSInteger respCode, NSString *respMsg) {
                        
                    }];
                    //                [[HSFPayManager sharedHSFPayManager] aliPayFunc_with_orderId:self.order_sn money:self.allPrice body:@"支付订单" subject:@"回车键"];
                }else{
                    
                    NSDictionary *dataDic = [responseObject objectForKey:@"data"];
                    NSString *out_trade_no = [NSString stringWithFormat:@"%@",[dataDic objectForKey:@"out_trade_no"]];
                    //微信支付
                    [[HSFPayManager sharedHSFPayManager] wechatPayFunc_with_orderId:out_trade_no money:_jineTF.text payTitle:@"今望" attach:@""];
                    
                }
                
            }
            
        } failure:^(id errorObject) {
            [self showBottomMessag:@"网络请求失败"];
        }];
    }
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
